package com.inspur.edp.formserver.viewmodel.common;


import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.inspur.edp.cef.designtime.api.entity.CustomizationInfo;
import com.inspur.edp.formserver.viewmodel.exception.ViewModelException;
import com.inspur.edp.formserver.viewmodel.json.model.ValueHelpConfigDeserizlizer;
import com.inspur.edp.formserver.viewmodel.json.model.ValueHelpConfigSerizlizer;
import com.inspur.edp.formserver.viewmodel.linkedconfig.LinkedConfigCollection;

import java.io.Serializable;

/**
 * The Definition Of Value Help Config
 *
 * @ClassName: ValueHelpConfig
 * @Author: Benjamin Gong
 * @Date: 2021/1/11 17:13
 * @Version: V1.0
 */
@JsonDeserialize(using = ValueHelpConfigDeserizlizer.class)
@JsonSerialize(using = ValueHelpConfigSerizlizer.class)
public class ValueHelpConfig implements Cloneable, Serializable {

    //region 字段
    /**
     * VM元素ID
     */
    private String elementId;
    /**
     * 允许自定义帮助权限
     */
    private boolean enableCustomHelpAuth;
    /**
     * HelperID
     */
    private String helperId;
    /**
     * 帮助过滤条件表达式
     */
    private String filterExpression;

    /**
     * 帮助扩展动作
     */
    private HelpExtendAction helpExtendAction;

    private CustomizationInfo customizationInfo;

    private LinkedConfigCollection linkedConfigs;
    //endregion


    ///#region 构造函数

    public ValueHelpConfig() {
    }

    /**
     * 构造函数
     *
     * @param elementId        VO元素ID
     * @param helperId         帮助元数据Id
     * @param filterExpression 过滤表达式
     */
    public ValueHelpConfig(String elementId, String helperId, String filterExpression) {
        this();
        setElementId(elementId);
        setHelperId(helperId);
        setFilterExpression(filterExpression);
    }

    ///#endregion

    ///#region 属性

    public final String getElementId() {
        return elementId;
    }

    public final void setElementId(String value) {
        elementId = value;
    }

    public final boolean getEnableCustomHelpAuth() {
        return enableCustomHelpAuth;
    }

    public final void setEnableCustomHelpAuth(boolean value) {
        enableCustomHelpAuth = value;
    }

    public final String getHelperId() {
        return helperId;
    }

    public final void setHelperId(String value) {
        helperId = value;
    }

    public final String getFilterExpression() {
        return filterExpression;
    }

    public final void setFilterExpression(String value) {
        filterExpression = value;
    }

    /**
     * 帮助扩展动作
     */
    public final HelpExtendAction getHelpExtend() {
        if (helpExtendAction == null) {
            helpExtendAction = new HelpExtendAction();
        }
        return helpExtendAction;
    }

    public final void setHelpExtend(HelpExtendAction value) {
        helpExtendAction = value;
    }

    public CustomizationInfo getCustomizationInfo() {
        return this.customizationInfo;
    }

    public void setCustomizationInfo(CustomizationInfo customizationInfo) {
        this.customizationInfo = customizationInfo;
    }

    public LinkedConfigCollection getLinkedConfigs() {
        if (this.linkedConfigs == null)
            this.linkedConfigs = new LinkedConfigCollection();
        return linkedConfigs;
    }

    public void setLinkedConfigs(LinkedConfigCollection linkedConfigs) {
        this.linkedConfigs = linkedConfigs;
    }
    ///#endregion

    ///#region 方法

    /**
     * 克隆
     *
     * @return 值帮助配置
     */
    public final ValueHelpConfig clone() {
//		return MemberwiseClone();
        Object tempVar = null;
        try {
            tempVar = super.clone();
        } catch (CloneNotSupportedException e) {
            throw new ViewModelException(e);
        }
        ValueHelpConfig obj = (ValueHelpConfig) ((tempVar instanceof ValueHelpConfig) ? tempVar : null);
        return obj;
    }

    ///#endregion
}